package com.zoffy.wmsbackend.controller;

import com.zoffy.wmsbackend.common.BaseResponse;
import com.zoffy.wmsbackend.common.ResultUtils;
import com.zoffy.wmsbackend.mapper.ChartMapper;
import com.zoffy.wmsbackend.model.echart.StockInOutSummaryByWarehouse;
import com.zoffy.wmsbackend.model.echart.StockInSummaryByWarehouse;
import com.zoffy.wmsbackend.model.echart.StockOutAmountSummaryByWarehouse;
import com.zoffy.wmsbackend.model.echart.StockOutSummaryByWarehouse;
import com.zoffy.wmsbackend.model.vo.report.GoodsQuantity;
import com.zoffy.wmsbackend.model.vo.report.StockDiffQuantity;
import com.zoffy.wmsbackend.service.ChartService;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@PreAuthorize("hasAuthority('admin')")
@RequestMapping("/chart")
public class ChartController {

    @Resource
    private ChartService chartService;
    @Resource
    private ChartMapper chartMapper;
    @GetMapping("/stock-in-out-count")
    public BaseResponse<StockInOutSummaryByWarehouse> getStockInOutCountByWarehouse() {
        List<StockInSummaryByWarehouse> stockInData = chartService.getStockInCountByWarehouse();
        List<StockOutSummaryByWarehouse> stockOutData = chartService.getStockOutCountByWarehouse();

        return ResultUtils.success(new StockInOutSummaryByWarehouse(stockInData, stockOutData));
    }

    @GetMapping("/stock-out-amount-summary")
    public BaseResponse<List<StockOutAmountSummaryByWarehouse>> getStockOutAmountSummaryByWarehouse() {
        List<StockOutAmountSummaryByWarehouse> stockOutAmountSummary = chartService.getStockOutAmountSummaryByWarehouse();
        return ResultUtils.success(stockOutAmountSummary);
    }

    @GetMapping("/stockDiff")
    public BaseResponse<List<StockDiffQuantity>> getStockDiff() {
        List<StockDiffQuantity> stockDiffQuantity = chartService.getStockDiffQuantity();
        return ResultUtils.success(stockDiffQuantity);
    }
    @GetMapping("/stock-in-goods-quantity")
    public BaseResponse<List<GoodsQuantity>> getStockInGoodsQuantity() {
        List<GoodsQuantity> stockInGoodsQuantity = chartMapper.getStockInGoodsQuantity();
        return ResultUtils.success(stockInGoodsQuantity);
    }
    @GetMapping("/stock-out-goods-quantity")
    public BaseResponse<List<GoodsQuantity>> getStockOutGoodsQuantity() {
        List<GoodsQuantity> stockInGoodsQuantity = chartMapper.getStockOutGoodsQuantity();
        return ResultUtils.success(stockInGoodsQuantity);
    }
}